package com.wbp.cms.core.customer.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.wbp.cms.client.customer.domain.CustomerDO;
import com.wbp.cms.client.customer.query.CustomerQuery;
import com.wbp.cms.core.dao.BaseDao;


/**
 * @Description:
 * @Department:
 * @author andy.lhc
 * @date 2016年3月6日 下午11:10:25
 */
@Repository("customerDAO")
public class CustomerDAO extends BaseDao {


  public Long insertCustomer(CustomerDO customerDO) {
    super.insert("CustomerMapper.insert", customerDO);
    return customerDO.getId();
  }

  public int updateCustomer(CustomerDO customerDO) {
    return super.update("CustomerMapper.update", customerDO);
  }

  public List<CustomerDO> queryCustomer(CustomerQuery customerQuery) {

    return super.selectList("CustomerMapper.query", customerQuery);
  }

  public Integer queryCustomerCount(CustomerQuery customerQuery) {

    Object obj = super.selectOneObject("CustomerMapper.queryCount", customerQuery);
    return obj == null ? 0 : (Integer) obj;
  }

  public CustomerDO queryCustomerById(Long id) {
    Object obj = super.selectOneObject("CustomerMapper.queryOne", id);
    return obj == null ? null : (CustomerDO) obj;
  }

  public List<CustomerDO> queryCustomerByUser(CustomerQuery customerQuery) {
    return super.selectList("CustomerMapper.queryCustomerByUser", customerQuery);
  }

  public Integer queryCustomerByUserCount(CustomerQuery customerQuery) {
    Object obj = super.selectOneObject("CustomerMapper.queryCustomerByUserCount", customerQuery);
    return obj == null ? 0 : (Integer) obj;
  }

}
